package com.luoboduner.moo.info.util;

/**
 * Configuration management
 *
 * @author <a href="https://github.com/rememberber">RememBerBer</a>
 * @since 2021/11/08.
 */
public class ConfigUtil extends ConfigBaseUtil {

  private static final ConfigUtil configUtil = new ConfigUtil();

  public static ConfigUtil getInstance() {
    return configUtil;
  }

  private ConfigUtil() {
    super();
  }


  private String serverIp;
  private String port;
  /**
   * 设备Id
   */
  private String equipId;
  /**
   * 学校编码
   */
  private String DeptId;

  private String freq;
  private String subjectId;

  private String subjectName;
  private String address;
  private boolean autoCheckUpdate;

  private boolean defaultMaxWindow;

  private boolean unifiedBackground;

  private String beforeVersion;

  private String theme;

  private String font;

  private int fontSize;

  public String getServerIp() {
    return setting.getStr("serverIp", "setting.common", "192.168.23.84");
  }

  public void setServerIp(String serverIp) {
    setting.putByGroup("serverIp", "setting.common", serverIp);
  }
  public String getPort() {
    return setting.getStr("port", "setting.common", "48081");
  }

  public void setPort(String port) {
    setting.putByGroup("port", "setting.common", port);
  }

  public String getEquipId() {
    return setting.getStr("equipId", "setting.common", "");
  }

  public void setEquipId(String equipId) {
    setting.putByGroup("equipId", "setting.common", equipId);
  }

  //  默认2分钟
  public String getFreq() {
    return setting.getStr("freq", "setting.common", "120");
  }

  public void setFreq(String freq) {
    setting.putByGroup("freq", "setting.common", freq);
  }

  public String getSubjectId() {
    return setting.getStr("subjectId", "setting.common", "");
  }

  public void setSubjectId(String subjectId) {
    setting.putByGroup("subjectId", "setting.common", subjectId);
  }

  public String getSubjectName() {
    return setting.getStr("subjectName", "setting.common", "");
  }

  public void setSubjectName(String subjectName) {
    setting.putByGroup("subjectName", "setting.common", subjectName);
  }

  public String getAddress() {
    return setting.getStr("address", "setting.common", "");
  }

  public void setAddress(String address) {
    setting.putByGroup("address", "setting.common", address);
  }

  public String getDeptId() {
    return setting.getStr("deptId", "setting.common", "");
  }

  public void setDeptId(String deptId) {
    setting.putByGroup("deptId", "setting.common", deptId);
  }


  public boolean isAutoCheckUpdate() {
    return setting.getBool("autoCheckUpdate", "setting.common", true);
  }

  public void setAutoCheckUpdate(boolean autoCheckUpdate) {
    setting.putByGroup("autoCheckUpdate", "setting.common", String.valueOf(autoCheckUpdate));
  }

  public boolean isDefaultMaxWindow() {
    return setting.getBool("defaultMaxWindow", "setting.normal", false);
  }

  public void setDefaultMaxWindow(boolean defaultMaxWindow) {
    setting.putByGroup("defaultMaxWindow", "setting.normal", String.valueOf(defaultMaxWindow));
  }

  public boolean isUnifiedBackground() {
    return setting.getBool("unifiedBackground", "setting.normal", true);
  }

  public void setUnifiedBackground(boolean unifiedBackground) {
    setting.putByGroup("unifiedBackground", "setting.normal", String.valueOf(unifiedBackground));
  }

  public String getBeforeVersion() {
    return setting.getStr("beforeVersion", "setting.common", "0.0.0");
  }

  public void setBeforeVersion(String beforeVersion) {
    setting.putByGroup("beforeVersion", "setting.common", beforeVersion);
  }

  public String getTheme() {
    return setting.getStr("theme", "setting.appearance", "Dark purple");
  }

  public void setTheme(String theme) {
    setting.putByGroup("theme", "setting.appearance", theme);
  }

  public String getFont() {
    if (SystemUtil.isLinuxOs()) {
      return setting.getStr("font", "setting.appearance", "Noto Sans CJK HK");
    }
    else if (SystemUtil.isMacOs()) {
      return setting.getStr("font", "setting.appearance", "PingFang SC");
    }
    else {
      return setting.getStr("font", "setting.appearance", "Microsoft YaHei");
    }
  }

  public void setFont(String font) {
    setting.putByGroup("font", "setting.appearance", font);
  }

  public int getFontSize() {
    return setting.getInt("fontSize", "setting.appearance", 13);
  }

  public void setFontSize(int fontSize) {
    setting.putByGroup("fontSize", "setting.appearance", String.valueOf(fontSize));
  }

}
